package com.sfd.message.remind.controller;

import cn.hutool.core.date.ChineseDate;
import com.sfd.message.remind.entity.Festival;
import com.sfd.message.remind.module.Result;
import com.sfd.message.remind.service.FestivalDefaultService;
import com.sfd.message.remind.service.FestivalService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 节假日提醒
 *
 * @author haden
 * @date 2022/9/7 14:19
 **/
@RestController
@RequestMapping("/festival")
public class FestivalRemindController {
    @Resource
    FestivalService festivalService;
    @Resource
    FestivalDefaultService festivalDefaultService;

    /**
     * 获取x年内所有的节假日数据并保存到数据库中
     *
     * @param years 数据 向前向后各推x年
     * @return 处理结果
     */
    @GetMapping("/create")
    public Result<String> createFestival(@RequestParam(value = "years") Integer years) {
        return festivalService.createFestival(years);
    }

    @GetMapping("/defaultFestival")
    public Result<String> defaultFestival() {
        return festivalDefaultService.defaultFestival();
    }

    @GetMapping("/get")
    public Result<List<Festival>> get() {
        return festivalService.getFestival(null);
    }
}
